//
//  HLBMPlayerManager.swift
//  HLSwiftWork
//
//  Created by hulinhu on 2018/6/14.
//  Copyright © 2018年 hulinhu. All rights reserved.
//

import UIKit
import BMPlayer

class HLBMPlayerManager {
    //单例
    static let shareSingleOne = HLBMPlayerManager()
    
    // 播放器
    var player = BMPlayer()
    
    // 设置 frame
    func setupFrame(frame :CGRect) {
        player.frame = frame
    }
    
    // 视图显示隐藏
    func setupPlayerShowOrHidden(isShow:Bool) {
        player.isHidden = isShow ? false : true
    }
    
    func setupPlayerVideoInfor(videoUrl : String ,videoName: String ) {
        
        let ref = BMPlayerResource(url: URL(string: videoUrl)!,
                                   name: videoName)
        player.setVideo(resource: ref)
        
        player.backBlock = { [unowned self] (isFullScreen) in
            if isFullScreen == true { return }
        }
    }
    
    // 全屏
    func setupFullScreen(intoFullScreen:Bool) {
        player.updateUI(intoFullScreen)
    }
    
    // 播放
    func setupPlay() {
        player.play()
    }
    
    // 暂停
    func setupPause() {
        player.pause()
    }
    
    //  是否正在播放
    func isPlaying() -> Bool {
        return player.isPlaying
    }

   
}

